package com.heima.controller;


import com.heima.domain.Patient;
import com.heima.service.IPatientService;
import com.heima.vo.CommonResult;
import com.heima.vo.PatientIdVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;

import javax.websocket.server.PathParam;

/**
 * <p>
 * 就诊人 前端控制器
 * </p>
 *
 * @author wangjiexin
 * @since 2023-01-29
 */
@RestController
@RequestMapping("/patient")
public class PatientController {
    @Autowired
    IPatientService iPatientService;


    @GetMapping("/list")
    public CommonResult getlist() {
        //查询就诊人
        return CommonResult.success(iPatientService.getlist());

    }

    //新增和修改就诊人
    @PostMapping("/save")
    public CommonResult add(@RequestBody Patient patient) {
        Boolean res = iPatientService.add(patient);

        return CommonResult.success(res);
    }

    @PostMapping("/remove")
    public CommonResult del(@RequestParam Integer patientId) {
        Boolean res= iPatientService.delById(patientId);

        return CommonResult.success(res);
    }

    @GetMapping
    public CommonResult byId(@RequestParam Integer patientId) {
        //通过传进来的id查询
        PatientIdVO res = iPatientService.selectById(patientId);
        return CommonResult.success(res);
    }


}

